//
//  SISSHouseInfoView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/7/20.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSCoopHouseInfoView.h"


@interface SISSCoopHouseInfoView ()

/// 房源信息编码Label
@property (weak, nonatomic) UILabel *houseInfoCodeLabel;
@property (weak, nonatomic) UILabel *houseInfoCodeTitleLabel;
/// 产权Label
@property (weak, nonatomic) UILabel *propertyLabel;
@property (weak, nonatomic) UILabel *propertyTitleLabel;
/// 小区Label
@property (weak, nonatomic) UILabel *neighborhoodLabel;
@property (weak, nonatomic) UILabel *neighborhoodTitleLabel;
/// 售价Label
@property (weak, nonatomic) UILabel *priceLabel;
@property (weak, nonatomic) UILabel *priceTitleLabel;
/// 户型Label
@property (weak, nonatomic) UILabel *houseTypeLabel;
@property (weak, nonatomic) UILabel *houseTypeTitleLabel;
/// 面积Label
@property (weak, nonatomic) UILabel *areaLabel;
@property (weak, nonatomic) UILabel *areaTitleLabel;
/// 楼层区间Label
@property (weak, nonatomic) UILabel *floorLabel;
@property (weak, nonatomic) UILabel *floorTitleLabel;
/// 朝向Label
@property (weak, nonatomic) UILabel *directionLabel;
@property (weak, nonatomic) UILabel *directionTitleLabel;
/// 建筑年代Label
@property (weak, nonatomic) UILabel *buildYearLabel;
@property (weak, nonatomic) UILabel *buildYearTitleLabel;
/// 装修程度Label
@property (weak, nonatomic) UILabel *decorationLabel;
@property (weak, nonatomic) UILabel *decorationTitleLabel;
/// 房屋优劣势Label
@property (weak, nonatomic) UILabel *houseDescLabel;
@property (weak, nonatomic) UILabel *houseDescTitleLabel;
/// 合作说明Label
@property (weak, nonatomic) UILabel *cooperationDescLabel;
@property (weak, nonatomic) UILabel *cooperationDescTitleLabel;

@end
@implementation SISSCoopHouseInfoView

- (void)setHouseCoopDetailModel:(SISSHouseCooperationDetailModel *)houseCoopDetailModel {
    _houseCoopDetailModel = houseCoopDetailModel;
    
    self.houseInfoCodeLabel.text = houseCoopDetailModel.houseInfoNo.length > 0 ? houseCoopDetailModel.houseInfoNo : @" ";
    self.propertyLabel.text = houseCoopDetailModel.propertyState;
    self.neighborhoodLabel.text = houseCoopDetailModel.neighbourhood;
    self.priceLabel.text = [NSString stringWithFormat:@"%@万",@(houseCoopDetailModel.price)];
    self.houseTypeLabel.text = houseCoopDetailModel.houseType;
    self.areaLabel.text = [NSString stringWithFormat:@"%@㎡",@(houseCoopDetailModel.area)];
    NSArray *floorsArr = @[@"1-10层", @"11-20层", @"21-30层", @"30层以上"];
    self.floorLabel.text = houseCoopDetailModel.floor ? floorsArr[houseCoopDetailModel.floor/11] : @"-";
    self.directionLabel.text = houseCoopDetailModel.direction;
    self.buildYearLabel.text = houseCoopDetailModel.year ? [NSString stringWithFormat:@"%zd年",houseCoopDetailModel.year] : @"";
    self.decorationLabel.text = houseCoopDetailModel.decoration;
    self.houseDescLabel.text = houseCoopDetailModel.otherdesc.length > 0 ? houseCoopDetailModel.otherdesc : @" ";
    self.cooperationDescLabel.text = houseCoopDetailModel.cooperation_desc.length > 0 ? houseCoopDetailModel.cooperation_desc : @" ";
}



#pragma mark - UI
- (void)initUI {
    [super initUI];
    self.backgroundColor = COLOR(0xF1F1F5);
    
    UILabel *houseInfoCodeTitleLabel = [[UILabel alloc] init];
    houseInfoCodeTitleLabel.text = @"房源信息编码：";
    houseInfoCodeTitleLabel.textColor = COLOR(0x8998A5);
    houseInfoCodeTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:houseInfoCodeTitleLabel];
    self.houseInfoCodeTitleLabel = houseInfoCodeTitleLabel;
    
    UILabel *houseInfoCodeLabel = [[UILabel alloc] init];
    houseInfoCodeLabel.text = @"U88974930";
    houseInfoCodeLabel.textAlignment = NSTextAlignmentLeft;
    houseInfoCodeLabel.textColor = MAIN_TEXT_COLOR;
    houseInfoCodeLabel.font = [UIFont boldSystemFontOfSize:15];
    houseInfoCodeLabel.numberOfLines = 0;
    [self addSubview:houseInfoCodeLabel];
    self.houseInfoCodeLabel = houseInfoCodeLabel;
    
    UILabel *propertyTitleLabel = [[UILabel alloc] init];
    propertyTitleLabel.text = @"产权：";
    propertyTitleLabel.textColor = COLOR(0x8998A5);
    propertyTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:propertyTitleLabel];
    self.propertyTitleLabel = propertyTitleLabel;
    
    UILabel *propertyLabel = [[UILabel alloc] init];
    propertyLabel.text = @"独有";
    propertyLabel.textColor = MAIN_TEXT_COLOR;
    propertyLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:propertyLabel];
    self.propertyLabel = propertyLabel;
    
    UILabel *neighborhoodTitleLabel = [[UILabel alloc] init];
    neighborhoodTitleLabel.text = @"小区：";
    neighborhoodTitleLabel.textColor = COLOR(0x8998A5);
    neighborhoodTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:neighborhoodTitleLabel];
    self.neighborhoodTitleLabel = neighborhoodTitleLabel;
    
    UILabel *neighborhoodLabel = [[UILabel alloc] init];
    neighborhoodLabel.text = @"dream小区";
    neighborhoodLabel.textColor = MAIN_TEXT_COLOR;
    neighborhoodLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:neighborhoodLabel];
    self.neighborhoodLabel = neighborhoodLabel;
    
    UILabel *priceTitleLabel = [[UILabel alloc] init];
    priceTitleLabel.text = @"售价：";
    priceTitleLabel.textColor = COLOR(0x8998A5);
    priceTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:priceTitleLabel];
    self.priceTitleLabel = priceTitleLabel;
    
    UILabel *priceLabel = [[UILabel alloc] init];
    priceLabel.text = @"800万";
    priceLabel.textColor = MAIN_TEXT_COLOR;
    priceLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:priceLabel];
    self.priceLabel = priceLabel;
    
    UILabel *houseTypeTitleLabel = [[UILabel alloc] init];
    houseTypeTitleLabel.text = @"户型：";
    houseTypeTitleLabel.textColor = COLOR(0x8998A5);
    houseTypeTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:houseTypeTitleLabel];
    self.houseTypeTitleLabel = houseTypeTitleLabel;
    
    UILabel *houseTypeLabel = [[UILabel alloc] init];
    houseTypeLabel.text = @"5房";
    houseTypeLabel.textColor = MAIN_TEXT_COLOR;
    houseTypeLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:houseTypeLabel];
    self.houseTypeLabel = houseTypeLabel;
    
    UILabel *areaTitleLabel = [[UILabel alloc] init];
    areaTitleLabel.text = @"面积：";
    areaTitleLabel.textColor = COLOR(0x8998A5);
    areaTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:areaTitleLabel];
    self.areaTitleLabel = areaTitleLabel;
    
    UILabel *areaLabel = [[UILabel alloc] init];
    areaLabel.text = @"200㎡";
    areaLabel.textColor = MAIN_TEXT_COLOR;
    areaLabel.font = [UIFont boldSystemFontOfSize:15];
    areaLabel.numberOfLines = 0;
    [self addSubview:areaLabel];
    self.areaLabel = areaLabel;
    
    UILabel *floorTitleLabel = [[UILabel alloc] init];
    floorTitleLabel.text = @"楼层区间：";
    floorTitleLabel.textColor = COLOR(0x8998A5);
    floorTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:floorTitleLabel];
    self.floorTitleLabel = floorTitleLabel;
    
    UILabel *floorLabel = [[UILabel alloc] init];
    floorLabel.text = @"10-20层";
    floorLabel.textColor = MAIN_TEXT_COLOR;
    floorLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:floorLabel];
    self.floorLabel = floorLabel;
    
    UILabel *directionTitleLabel = [[UILabel alloc] init];
    directionTitleLabel.text = @"朝向：";
    directionTitleLabel.textColor = COLOR(0x8998A5);
    directionTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:directionTitleLabel];
    self.directionTitleLabel = directionTitleLabel;
    
    UILabel *directionLabel = [[UILabel alloc] init];
    directionLabel.text = @"朝东";
    directionLabel.textColor = MAIN_TEXT_COLOR;
    directionLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:directionLabel];
    self.directionLabel = directionLabel;
    
    UILabel *buildYearTitleLabel = [[UILabel alloc] init];
    buildYearTitleLabel.text = @"建筑年代：";
    buildYearTitleLabel.textColor = COLOR(0x8998A5);
    buildYearTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:buildYearTitleLabel];
    self.buildYearTitleLabel = buildYearTitleLabel;
    
    UILabel *buildYearLabel = [[UILabel alloc] init];
    buildYearLabel.text = @"建筑年代";
    buildYearLabel.textColor = MAIN_TEXT_COLOR;
    buildYearLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:buildYearLabel];
    self.buildYearLabel = buildYearLabel;
    
    UILabel *decorationTitleLabel = [[UILabel alloc] init];
    decorationTitleLabel.text = @"装修程度：";
    decorationTitleLabel.textColor = COLOR(0x8998A5);
    decorationTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:decorationTitleLabel];
    self.decorationTitleLabel = decorationTitleLabel;
    
    UILabel *decorationLabel = [[UILabel alloc] init];
    decorationLabel.text = @"精装";
    decorationLabel.textColor = MAIN_TEXT_COLOR;
    decorationLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:decorationLabel];
    self.decorationLabel = decorationLabel;
    
    UILabel *houseDescTitleLabel = [[UILabel alloc] init];
    houseDescTitleLabel.text = @"房屋优劣势：";
    houseDescTitleLabel.textColor = COLOR(0x8998A5);
    houseDescTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:houseDescTitleLabel];
    self.houseDescTitleLabel = houseDescTitleLabel;
    
    UILabel *houseDescLabel = [[UILabel alloc] init];
    houseDescLabel.text = @"顺分顺水，环境优美";
    houseDescLabel.numberOfLines = 0;
    houseDescLabel.textColor = MAIN_TEXT_COLOR;
    houseDescLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:houseDescLabel];
    self.houseDescLabel = houseDescLabel;
    
    UILabel *cooperationDescTitleLabel = [[UILabel alloc] init];
    cooperationDescTitleLabel.text = @"合作说明：";
    cooperationDescTitleLabel.textColor = COLOR(0x8998A5);
    cooperationDescTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:cooperationDescTitleLabel];
    self.cooperationDescTitleLabel = cooperationDescTitleLabel;
    
    UILabel *cooperationDescLabel = [[UILabel alloc] init];
    cooperationDescLabel.text = @"合作愉快";
    cooperationDescLabel.numberOfLines = 0;
    cooperationDescLabel.textColor = MAIN_TEXT_COLOR;
    cooperationDescLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:cooperationDescLabel];
    self.cooperationDescLabel = cooperationDescLabel;
    
}

#pragma mark - 布局
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.houseInfoCodeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(margin);
        make.top.equalTo(weakSelf).offset(3 * margin);
    }];
    [self.houseInfoCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseInfoCodeTitleLabel.mas_right);
        make.top.equalTo(weakSelf.houseInfoCodeTitleLabel);
    }];
    
    [self.propertyTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseInfoCodeTitleLabel);
        make.top.equalTo(weakSelf.houseInfoCodeLabel.mas_bottom).offset(2 * margin);
    }];
    [self.propertyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.propertyTitleLabel);
    }];
    
    [self.neighborhoodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyTitleLabel);
        make.top.equalTo(weakSelf.propertyTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.neighborhoodLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.neighborhoodTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.neighborhoodTitleLabel);
    }];
    
    [self.priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.neighborhoodTitleLabel);
        make.top.equalTo(weakSelf.neighborhoodTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.priceTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.priceTitleLabel);
    }];
    
    [self.houseTypeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.priceTitleLabel);
        make.top.equalTo(weakSelf.priceTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.houseTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseTypeTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.houseTypeTitleLabel);
    }];
    
    [self.areaTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseTypeTitleLabel);
        make.top.equalTo(weakSelf.houseTypeTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.areaTitleLabel.mas_right);
        make.top.equalTo(weakSelf.areaTitleLabel);
    }];
    
    [self.floorTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.areaTitleLabel);
        make.top.equalTo(weakSelf.areaLabel.mas_bottom).offset(2 * margin);
    }];
    [self.floorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.floorTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.floorTitleLabel);
    }];
    
    [self.directionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.floorTitleLabel);
        make.top.equalTo(weakSelf.floorTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.directionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.directionTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.directionTitleLabel);
    }];
    
    [self.buildYearTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.directionTitleLabel);
        make.top.equalTo(weakSelf.directionTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.buildYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.buildYearTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.buildYearTitleLabel);
    }];
    
    [self.decorationTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.buildYearTitleLabel);
        make.top.equalTo(weakSelf.buildYearTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.decorationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.decorationTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.decorationTitleLabel);
    }];
    
    [self.houseDescTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.decorationTitleLabel);
        make.top.equalTo(weakSelf.decorationTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.houseDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseDescTitleLabel.mas_right);
        make.top.equalTo(weakSelf.houseDescTitleLabel);
        make.right.equalTo(weakSelf);
    }];
    
    [self.cooperationDescTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseDescTitleLabel);
        make.top.equalTo(weakSelf.houseDescLabel.mas_bottom).offset(2 * margin);
    }];
    [self.cooperationDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.cooperationDescTitleLabel.mas_right);
        make.top.equalTo(weakSelf.cooperationDescTitleLabel);
        make.right.equalTo(weakSelf);
        make.bottom.equalTo(weakSelf).offset(-margin);
    }];
    
}


@end
